package tickets.tickets;

/**
 * One of base ticket decorators.
 * 
 * @author Hlib_Babii
 */
public class LimitedTravelsTicket extends LimitedTicket {

    private int nTravels;

    LimitedTravelsTicket(Ticket ticket, int nTravels) {
        super(ticket);
        this.nTravels = nTravels;
    }

    @Override
    PassageState check() {
        if (nTravels > 0) {
            return baseTicket.check();
        }
        return PassageState.NO_TRAVELS_LEFT;
    }

    @Override
    void use() {
        // assert nTravels > 0;

        --nTravels;
        baseTicket.use();
    }
}
